﻿using DXApplicationTangche.UC.成品出库单.service;
using DXApplicationTangche.UC.门店出入库.Service;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DXApplicationTangche.UC.门店出入库
{
    public partial class Form其他出入库 : DevExpress.XtraEditors.XtraForm
    {
        private StockInOutDetailDTO otherStockInOutDetailDTO = new StockInOutDetailDTO();
        private List<StockInOutDetailDTO> otherStockInOutDetailDTOs = new List<StockInOutDetailDTO>();
        public Form其他出入库()
        {
            InitializeComponent();
        }

        private void textBox扫描成衣码_KeyDown(object sender, KeyEventArgs e)
        {
            if(e.KeyValue == 13)
            {
                if (!String.IsNullOrWhiteSpace(this.textBox扫描成衣码.Text.Trim()))
                {
                    //扫码条码不为空，入库到抖音仓
                    this.otherStockInOutDetailDTO = 出入库Service.otherStockIn(this.textBox扫描成衣码.Text.Trim(), "7");
                    //尺寸清洗
                    try { this.otherStockInOutDetailDTO.styleSizeCd = this.otherStockInOutDetailDTO.styleSizeCd.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
                    //如果扫码返回值dto中barcode不为空，一览数据刷新
                    if (!String.IsNullOrEmpty(this.otherStockInOutDetailDTO.barcode))
                    {
                        if (this.otherStockInOutDetailDTOs.Count > 0)
                        {
                            //去重，如果条码已扫则同样条码一览进不去
                            if (!this.otherStockInOutDetailDTOs.Exists(dto => dto.barcode.Equals(this.otherStockInOutDetailDTO.barcode)))
                            {
                                this.otherStockInOutDetailDTOs.Add(this.otherStockInOutDetailDTO);
                            }
                        }
                        else
                        {
                            this.otherStockInOutDetailDTOs.Add(this.otherStockInOutDetailDTO);
                        }
                    }
                    //gridControl赋值
                    this.gridControl其他入库.DataSource = this.otherStockInOutDetailDTOs;
                    this.gridView其他入库.RefreshData();
                    this.gridView其他入库.BestFitColumns();
                    this.textBox扫描成衣码.Clear();
                }
                else
                {
                    MessageBox.Show("请扫码");
                    return;
                }
            }
        }
    }
}
